#refer: https://book.aishangwei.net/blog-7.html#6y292

echo "初始化k8s master"
kubeadm init \
--image-repository registry.aliyuncs.com/google_containers \
--control-plane-endpoint k8s-master.cn:6443 \
--apiserver-advertise-address=192.168.56.200 \
--pod-network-cidr=10.244.0.0/16

#配置用户认证证书
mkdir -p $HOME/.kube
cp -i /etc/kubernetes/admin.conf  $HOME/.kube/config
chown  $(id -u):$(id -g)  $HOME/.kube/config

echo "检查pods"
kubectl get pods -A
sleep 10

#kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml
kubectl apply -f https://gitee.com/bigbigwood/infra/raw/master/k8s/centos8/kube-flannel.yml

echo "检查pods"
kubectl get pods -A